//
//  GB_UserBasicInfoViewController.m
//  MELive
//
//  Created by 郭宝 on 16/10/24.
//  Copyright © 2016年 郭宝. All rights reserved.
//

#import "GB_UserBasicInfoViewController.h"
#import "ZWYNetTool.h"
#import "GB_UserBaseInfo.h"
#import "GB_UserBaseInfoData.h"
#import "GB_UserBaseInfoUseraccount.h"
#import "GB_UserBaseInfoUseralbum.h"
#import "GB_UserBaseInfoUserbasicinfo.h"
#import "GB_UserRoom.h"
#import "GB_UserRoomData.h"
#import "YYModel.h"
#import "GB_UserTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Macro.h"
#import "GB_UserHandselList.h"
#import "GB_UserHandselListData.h"
#import "GB_UserHandselListUserbasicinfo.h"
@interface GB_UserBasicInfoViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) GB_UserBaseInfo *user;
@property (nonatomic, strong) GB_UserRoom *room;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIView *tableHeaderView;
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (nonatomic, strong) GB_UserHandselList *handsel;
@end

@implementation GB_UserBasicInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    _tableHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 200);
    [_tableView registerNib:[UINib nibWithNibName:@"GB_UserTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"GB_UserTableViewCell"];
    [ZWYNetTool GET:[NSString stringWithFormat:@"http://api1.naonaola.com/user?otherUserId=%ld", _userId] andBody:nil andHeader:@{@"token": @"6347e2e2-42d5-46d5-9e75-28d3e3d03237"} andResponse:ZWYJSON andSuccessBlock:^(id result) {
        _user = [GB_UserBaseInfo yy_modelWithJSON:result];
        [_tableView reloadData];
    } andFailureBlock:^(NSError *error) {
    }];
    [ZWYNetTool GET:[NSString stringWithFormat:@"http://api1.naonaola.com/user/rooms?otherUserId=%ld", _userId] andBody:nil andHeader:@{@"token": @"6347e2e2-42d5-46d5-9e75-28d3e3d03237"} andResponse:ZWYJSON andSuccessBlock:^(id result) {
        _room = [GB_UserRoom yy_modelWithJSON:result];
        
        [_tableView reloadData];
    } andFailureBlock:^(NSError *error) {
        
    }];
    [ZWYNetTool GET:[NSString stringWithFormat:@"http://api1.naonaola.com/user/handsel/list?otherUserId=%ld", _userId] andBody:nil andHeader:@{@"token": @"6347e2e2-42d5-46d5-9e75-28d3e3d03237"} andResponse:ZWYJSON andSuccessBlock:^(id result) {
        _handsel = [GB_UserHandselList yy_modelWithJSON:result];
        NSLog(@"%@", _handsel.data[0].userBasicInfo.nickName);
        [_tableView reloadData];
    } andFailureBlock:^(NSError *error) {
        
    }];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    GB_UserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GB_UserTableViewCell"];
    [_avatarImageView sd_setImageWithURL:[NSURL URLWithString:_user.data.userBasicInfo.avatar]];

    return cell;
}
- (void)handleData {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
